package com.ternnetwork.configuration.controller.system;

import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.ternnetwork.commons.model.http.BaseResponse;
import com.ternnetwork.commons.utils.PrintWriterUtils;
import com.ternnetwork.configuration.entity.system.SystemParameter;
import com.ternnetwork.configuration.service.system.SystemParameterService;
import com.ternnetwork.persistence.page.Page;




@Controller
@RequestMapping("/configuration/system/parameter/*")
public class SystemParameterController {
	
	@SuppressWarnings("restriction")
	@Resource
	private SystemParameterService systemParameterService;

	
	@RequestMapping("manage.htm")
	public ModelAndView manage(){
		return new ModelAndView("/WEB-INF/view/configuration/system/system_parameter_manage.jsp");
	}
	
	@RequestMapping("query.htm")
	public void query(PrintWriter out,HttpServletResponse response,String sort,String order,int limit, int offset,SystemParameter t){
		Page page=Page.createPage(limit, offset);
		PrintWriterUtils.printString(out, response, systemParameterService.queryToJsonStr(t, page));
	}
	
	@RequestMapping("add.htm")
	public @ResponseBody BaseResponse add(SystemParameter t){
		return systemParameterService.idoAdd(t);
	}
	
	@RequestMapping("update.htm")
	public @ResponseBody  BaseResponse update(SystemParameter t){
	    return systemParameterService.idoUpdate(t);
	}
	
	@RequestMapping("delete.htm")
	public  @ResponseBody  BaseResponse delete(long id){
		return systemParameterService.idoDeleteById(id);
	}
}
